#include	"../include/Tickable.h"
#include	<list>

static std::list<ITickable *> g_tickables;

ITickable::ITickable() : _breath_weight(0) {
	g_tickables.push_back(this);
}

ITickable::ITickable(int weight) : _breath_weight(weight) {
	g_tickables.push_front(this);
	g_tickables.sort([](ITickable * l, ITickable * r) {
		return l->_breath_weight > r->_breath_weight;
	});
}

ITickable::~ITickable() {
	g_tickables.remove(this);
}

void ITickable::BreathAll() {
	for (auto p : g_tickables) p->OnBreath();
}